﻿using HCDV;
using HCDV.HCSP;
using hcrainMvc.ashx.ywfunction;
using hrainwebbase.ashx.spfunction;
using hrainwebbase.basecs;
using Newtonsoft.Json;
//using hcrainMvc.BLL;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Http;

namespace hcrainMvc.Controllers
{
    public class HcrainController : ApiController
    {
        /// <summary>
        /// 从字符串中获取 非数值码与数值及长度 
        /// 如  A0012F0009 返回 A0012F, 9 ,4(0009)
        /// 如  A0012F0009A  返回 A0012F0009A, 0, 0(空)
        /// </summary>
        /// <param name="codeinfo"></param>
        /// <returns></returns>
        [ActionName("GetCodeNum")]
        [HttpGet]
        public object GetCodeNum(string codeinfo)
        {
            var info = simplefunction.hcrainFunction_getCodeNum(codeinfo);
            return new { codestring = info[0], codenum = info[1], codenuml = info[2] };

        }

        /// <summary>
        /// 格式化
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        [ActionName("ReSetCodeInfo")]
        [HttpPost]
        public codeinfo ReSetCodeInfo(codeinfo code)
        {
            return ywfunction.ReSetCodeInfo(code);

        }
        /// <summary>
        /// 检查是否有重复,是否有效 1代码OK  其它代表异常信息
        /// </summary>
        /// <param name="codelist"></param>
        /// <returns></returns>
        [ActionName("PostCheckCodeListIsOk")]
        [HttpPost]
        public string PostCheckCodeListIsOk(List<codeinfo> codelist)
        {
            return DoPostCheckCodeListIsOk(codelist, true);
        }
        /// <summary>
        /// 检查是否有重复,是否有效 1代码OK  其它代表异常信息
        /// </summary>
        /// <param name="codelist"></param>
        /// <returns></returns>
        [ActionName("PostCheckCodeListIsOkNoDB")]
        [HttpPost]
        public string PostCheckCodeListIsOkNoDB(List<codeinfo> codelist)
        {
            return DoPostCheckCodeListIsOk(codelist, false);
        }
        private string DoPostCheckCodeListIsOk(List<codeinfo> codelist, bool ischekdb = true)
        {
            List<codeinfo> codeinfolist = new List<codeinfo>();
            foreach (var code in codelist)
            {
                if (code.startCode == null && code.endCode == null) continue;
                if (code.startCode == "" && code.endCode == "") continue;
                if (code.startCode == null || code.endCode == null || code.startCode.Length != code.endCode.Length)
                {
                    return code.startCode + "与" + code.endCode + " 长度不一致!";
                }
                //格式化
                var code2 = ReSetCodeInfo(code);
                //同一个号段
                if (code2.endcodeString != code2.codeString)
                    return code.startCode + "与" + code.endCode + " 不是同一个号段噢!";
                //数值结束的要是数值
                if (code.startCode.Length == code2.codeString.Length)
                    return code.startCode + "与" + code.endCode + " 号段应该以数值结尾!";

                //结束数值>=开始
                if (code2.startNum > code2.endNum)
                    return code.startCode + "与" + code.endCode + " 结束码应该大于等于开始码!";
                if (ischekdb)
                {
                    //在库内
                    //   hcdoselbyPost("id,fv5,fv6", "yw_baseinfo", "type=20171015 and  fv7='" + $("#ffv7").val() + "' and ((nv1<=" + $("#fnv1").val() + " and nv3>=" + $("#fnv1").val() + ") or  (nv1<=" + $("#fnv3").val() + " and nv3>=" + $("#fnv3").val() + ") )  " + addwhere,
                    DataTable dt = null;
                    using (dbsimple db = new dbsimple())
                    {
                        if (string.IsNullOrEmpty(code2.codeString)) dt = db.Query(string.Format("select id from yw_baseinfo where type=20171015  and  maintype=20171015 and (fv7='' or fv7 is null) and (nv1<={1} and nv3>={1}) and  (nv1<={2} and nv3>={2}) and nv2={3} order by dataaddtime asc",
                            code2.codeString, code2.startNum, code2.endNum, code2.NumLenth));
                        else
                            dt = db.Query(string.Format("select id from yw_baseinfo where type=20171015  and  maintype=20171015 and fv7='{0}' and (nv1<={1} and nv3>={1}) and  (nv1<={2} and nv3>={2}) and nv2={3} order by dataaddtime asc",
                         code2.codeString, code2.startNum, code2.endNum, code2.NumLenth));
                        if (dt == null || dt.Rows.Count == 0)
                            return code.startCode + "-" + code.endCode + " 不在库内!";
                    }
                }
                //是否有记录了
                var re = codeinfolist.FirstOrDefault(m =>
                    m.codeString == code2.codeString && m.NumLenth == code2.NumLenth
                    && ((m.startNum <= code2.startNum && code2.startNum <= m.endNum) || (m.startNum <= code2.endNum && code2.endNum <= m.endNum))
                    );
                if (re != null)
                {
                    return re.startCode + "--" + code.startCode + " 的两个段号重复了!";
                }


                codeinfolist.Add(code2);
            }

            return "1";
        }

        /// <summary>
        /// 出库处理
        /// </summary>
        /// <param name="codelist"></param>
        /// <returns></returns>
        [ActionName("PostOutCodeListIsOk")]
        [HttpPost]
        public string PostOutCodeListIsOk(List<codeinfo> codelist)
        {
            return ywfunction.PostOutCodeListIsOk(codelist);
            //List<codeinfo> codeinfolist = new List<codeinfo>();
            foreach (var code in codelist)
            {
                if (code.startCode == null && code.endCode == null) continue;
                if (code.startCode == "" && code.endCode == "") continue;
                if (code.startCode == null || code.endCode == null || code.startCode.Length != code.endCode.Length)
                {
                    return code.startCode + "与" + code.endCode + " 长度不一致!";
                }
                //格式化
                var code2 = ReSetCodeInfo(code);

                #region 这里不再分析是有效了，提交前已经处理了一次

                ////同一个号段
                //if (code2.endcodeString != code2.codeString)
                //    return code.startCode + "与" + code.endCode + " 不是同一个号段噢!";
                ////数值结束的要是数值
                //if (code.startCode.Length == code2.codeString.Length)
                //    return code.startCode + "与" + code.endCode + " 号段应该以数值结尾!";

                ////结束数值>=开始
                //if (code2.startNum > code2.endNum)
                //    return code.startCode + "与" + code.endCode + " 结束码应该大于等于开始码!";

                ////在库内
                ////   hcdoselbyPost("id,fv5,fv6", "yw_baseinfo", "type=20171015 and  fv7='" + $("#ffv7").val() + "' and ((nv1<=" + $("#fnv1").val() + " and nv3>=" + $("#fnv1").val() + ") or  (nv1<=" + $("#fnv3").val() + " and nv3>=" + $("#fnv3").val() + ") )  " + addwhere,
                //DataTable dt = null;
                //using (dbsimple db = new dbsimple())
                //{
                //    dt = db.Query(string.Format("select id from yw_baseinfo where type=20171015  and  maintype=20171015 and fv7='{0}' and (nv1<={1} and nv3>={1}) and  (nv1<={2} and nv3>={2}) order by dataaddtime asc",
                //        code2.codeString, code2.startNum, code2.endNum));
                //    if (dt == null || dt.Rows.Count == 0)
                //        return code.startCode + "-" + code.endCode + " 不在库内!";
                //}
                ////是否有记录了
                //var re = codeinfolist.FirstOrDefault(m =>
                //    m.codeString == code2.codeString
                //    && ((m.startNum <= code2.startNum && code2.startNum <= m.endNum) || (m.startNum <= code2.endNum && code2.endNum <= m.endNum))
                //    );
                //if (re != null)
                //{
                //    return re.startCode + "--" + code.startCode + " 的两个段号重复了!";
                //}
                //codeinfolist.Add(code2);
                #endregion

                #region 出库处理
                DataTable dt = null;
                using (dbsimple db = new dbsimple())
                {
                    if (string.IsNullOrEmpty(code2.codeString)) dt = db.Query(string.Format("select * from yw_baseinfo where type=20171015  and  maintype=20171015 and( fv7='' or fv7 is null) and (nv1<={1} and nv3>={1}) and  (nv1<={2} and nv3>={2}) and nv2={3}",
                        code2.codeString, code2.startNum, code2.endNum, code2.NumLenth));
                    else
                        dt = db.Query(string.Format("select * from yw_baseinfo where type=20171015  and  maintype=20171015 and fv7='{0}' and (nv1<={1} and nv3>={1}) and  (nv1<={2} and nv3>={2}) and nv2={3}",
                        code2.codeString, code2.startNum, code2.endNum, code2.NumLenth));
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        //以开始号出库
                        if (code2.startNum == double.Parse(dt.Rows[0]["nv1"].ToString()))
                        {
                            //部分出库--更新段号
                            if (code2.endNum < double.Parse(dt.Rows[0]["nv3"].ToString()))
                            {
                                //fv5开始号
                                //Fv6结束号
                                //Fv7 非数值部分',
                                //Nv1  开始号 '数值',
                                //Nv2 开始号'数值长度',
                                //Nv3  结束号 '数值',
                                //Nv4 结束号'数值长度',
                                //Nv5 数量
                                db.exe(string.Format("update yw_baseinfo set fv5 ='{0}',nv1={1},nv5={2}  where id={3}",
                                    simplefunction.getCodeSet0(dt.Rows[0]["fv7"].ToString(), (code2.endNum + 1).ToString(), code2.startCode.Length),
                                    code2.endNum + 1, //开始号数值
                                    double.Parse(dt.Rows[0]["nv3"].ToString()) - code2.endNum,//还有
                                    dt.Rows[0]["id"].ToString()
                                    ));
                            }
                            else//全部出库
                            {
                                db.exe(string.Format("delete from  yw_baseinfo where id={0}", dt.Rows[0]["id"].ToString()));
                            }

                        }
                        else//以中间开始出库
                        {
                            //后面全部出库--更新段号
                            if (code2.endNum >= double.Parse(dt.Rows[0]["nv3"].ToString()))
                            {
                                db.exe(string.Format("update yw_baseinfo set fv6 ='{0}',nv3={1},nv5={2}  where id={3}",
                                    simplefunction.getCodeSet0(dt.Rows[0]["fv7"].ToString(), (code2.startNum - 1).ToString(), code2.startCode.Length),
                                    code2.startNum - 1, //结束号数值
                                     code2.startNum - double.Parse(dt.Rows[0]["nv1"].ToString()),//还有
                                    dt.Rows[0]["id"].ToString()
                                    ));
                            }
                            else//只出中间一段
                            {
                                //将原有的更新结束部分

                                //fv5开始号
                                //Fv6结束号
                                //Fv7 非数值部分',
                                //Nv1  开始号 '数值',
                                //Nv2 开始号'数值长度',
                                //Nv3  结束号 '数值',
                                //Nv4 结束号'数值长度',
                                //Nv5 数量
                                db.exe(string.Format("update yw_baseinfo set fv6 ='{0}',nv3={1},nv5={2}  where id={3}",
                                    simplefunction.getCodeSet0(dt.Rows[0]["fv7"].ToString(), (code2.startNum - 1).ToString(), code2.startCode.Length),
                                    code2.startNum - 1, //结束号数值
                                     code2.startNum - double.Parse(dt.Rows[0]["nv1"].ToString()),//还有
                                    dt.Rows[0]["id"].ToString()
                                    ));
                                //插入后面部分
                                DataRow drnew = dt.Rows[0];
                                Hashtable allinfo = new Hashtable();
                                allinfo.Add("tablename", "yw_baseinfo");
                                allinfo.Add("ftype", dt.Rows[0]["type"].ToString());
                                allinfo.Add("ftypename", dt.Rows[0]["typename"].ToString());
                                allinfo.Add("fmaintype", dt.Rows[0]["maintype"].ToString());
                                allinfo.Add("ffv1", dt.Rows[0]["fv1"].ToString());
                                allinfo.Add("ffv2", dt.Rows[0]["fv2"].ToString());
                                allinfo.Add("ffv3", dt.Rows[0]["fv3"].ToString());
                                allinfo.Add("ffv4", dt.Rows[0]["fv4"].ToString());
                                allinfo.Add("ffv5", simplefunction.getCodeSet0(dt.Rows[0]["fv7"].ToString(), (code2.endNum + 1).ToString(), code2.startCode.Length));//
                                allinfo.Add("ffv6", dt.Rows[0]["fv6"].ToString());
                                allinfo.Add("ffv7", dt.Rows[0]["fv7"].ToString());
                                allinfo.Add("fnv1", (code2.endNum + 1).ToString());//
                                allinfo.Add("fnv2", dt.Rows[0]["nv2"].ToString());
                                allinfo.Add("fnv3", dt.Rows[0]["nv3"].ToString());
                                allinfo.Add("fnv4", dt.Rows[0]["nv4"].ToString());
                                allinfo.Add("fnv5", double.Parse(dt.Rows[0]["nv3"].ToString()) - code2.endNum);// 结束号 '数值'-code2.endNum


                                allinfo.Add("fdataadduserid", dt.Rows[0]["dataadduserid"].ToString());
                                allinfo.Add("fdatabranchid", dt.Rows[0]["databranchid"].ToString());
                                allinfo.Add("fdatadepid", dt.Rows[0]["datadepid"].ToString());
                                allinfo.Add("fdatadepname", dt.Rows[0]["datadepname"].ToString());
                                allinfo.Add("fdatabranchname", dt.Rows[0]["databranchname"].ToString());
                                allinfo.Add("fdataaddusername", dt.Rows[0]["dataaddusername"].ToString());
                                allinfo.Add("fdataaddtime", dt.Rows[0]["dataaddtime"].ToString());

                                string erinfo;
                                bool re = ObjIUD.insertInfo(allinfo, out erinfo);


                            }
                        }

                    }
                }

                #endregion
            }

            return "1";
        }



        /// <summary>
        /// 根据基地ID，品种ID 要取的数据 获取贴码列表
        /// </summary>
        /// <param name="gjid"></param>
        /// <param name="spid"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        [ActionName("GetOutCodeList")]
        [HttpGet]
        public List<codeinfo> GetOutCodeList(string gjid, string spid, double count)
        {
            return ywfunction.GetOutCodeList(gjid, spid, count);
        }
        //[ActionName("UserInfoa")]
        //[HttpPost]
        //public hcrainMvc.Model.hsc_task test2(hcrainMvc.Model.hsc_task task)
        //{
        //    var ses = (LoginUser)HttpContext.Current.Session["LoginUser"];
        //    hsc_task t = new hsc_task();
        //    t.Add(task);
        //    task.newwork = ses.UserName + "2222";
        //    return task;
        //}
        /// <summary>
        /// 采摘出库 校验
        /// </summary>
        /// <param name="worklist"></param>
        /// <returns></returns>
        [ActionName("PostCheckStoreOutOk")]
        [HttpPost]
        public string PostCheckCodeListIsOk(List<workstoreoutinfo> worklist)
        {
            using (dbsimple db = new dbsimple())
            {
                foreach (var info in worklist)
                {

                    if (db.Query(string.Format("select id from hsc_task_store where id={0} and hasoutall+{1}>storeall",
                         info.id, info.number)).Rows.Count > 0)
                    {
                        return info.info + " 库存少于：" + info.number.ToString();
                    }
                }
            }

            return "ok";
        }
        /// <summary>
        /// 加工出库 校验
        /// </summary>
        /// <param name="worklist"></param>
        /// <returns></returns>
        [ActionName("PostCheckJGStoreOutOk")]
        [HttpPost]
        public string PostCheckJGStoreOutOk(List<workstoreoutinfo> worklist)
        {
            using (dbsimple db = new dbsimple())
            {
                foreach (var info in worklist)
                {

                    if (db.Query(string.Format("select id from hsc_task_process_work where id={0} and hasoutall+{1}>storeall",
                         info.id, info.number)).Rows.Count > 0)
                    {
                        return info.info + " 库存少于：" + info.number.ToString();
                    }
                }
            }
            return "ok";
        }

        /// <summary>
        /// 半成品出库 校验
        /// </summary>
        /// <param name="worklist"></param>
        /// <returns></returns>
        [ActionName("PostCheckBCPStoreOutOk")]
        [HttpPost]
        public string PostCheckBCPStoreOutOk(List<workstoreoutinfo> worklist)
        {
            using (dbsimple db = new dbsimple())
            {
                foreach (var info in worklist)
                {

                    if (db.Query(string.Format("select id from hsc_task_store where id={0} and ((hasoutall+{1}>storeall) or (storefortype1out +{2} >  storefortype1) or ( storefortype2out +{3} > storefortype2 ) or   (storefortype3out +{4} > storefortype3 ))",
                         info.id, info.number, info.numberb1, info.numberb2, info.numberb3
                         )).Rows.Count > 0)
                    {
                        return string.Format(info.info + " 库存不足 {0}/ {1} /{2} :{3}", info.numberb1, info.numberb2, info.numberb3, info.number);
                    }
                }
            }

            return "ok";
        }

        [ActionName("PostHcRainSql")]
        [HttpPost]
        public int PostHcRainSql(string sql)
        {
            using (dbsimple db = new dbsimple())
            {
                return db.exe(sql);
            }
        }


        /// <summary>
        /// 出库记录-删除处理
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        [ActionName("OutStoreGoBack")]
        [HttpPost]
        public int OutStoreGoBack(simpledata obj)
        {
            using (dbsimple db = new dbsimple())
            {
                //取出所有相关记录
                DataTable all = db.Query("select id,fromid,count from herp_inoutorderlist where ordergid='" + obj.id + "' and dataisdeleted=0");
                foreach (DataRow dr in all.Rows)
                {
                    //标识删除
                    db.SpExe("update herp_inoutorderlist set dataisdeleted=1 where id=" + dr["id"].ToString());
                    //还原对应的入库记录
                    if (!string.IsNullOrEmpty(dr["fromid"].ToString()))
                    {
                        db.SpExe("update herp_inoutorderlist set hasout=hasout-" + dr["count"].ToString() + " where id=" + dr["fromid"].ToString());
                    }

                }
                //删除对应的作业记录如果有
                db.SpExe("delete  from  hsc_task_info  where pcgid='" + obj.id + "'");
                return 0;
            }
        }
        /// <summary>
        /// 更新已出库的记录
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        [ActionName("OutStoreUpdate")]
        [HttpPost]
        public int OutStoreUpdate(OutListOutUpdate obj)
        {
            using (dbsimple db = new dbsimple())
            {
                //取出所有相关记录
                DataTable all = db.Query("select id,fromid,count from herp_inoutorderlist where id='" + obj.listoutid + "' and dataisdeleted=0");
                foreach (DataRow dr in all.Rows)
                {
                    //还原对应的入库记录
                    if (!string.IsNullOrEmpty(dr["fromid"].ToString()))
                    {
                        db.SpExe("update herp_inoutorderlist set hasout=hasout+" + dr["count"].ToString() + "-" + obj.oldcount + " where id=" + dr["fromid"].ToString());
                    }

                }

                return 0;
            }
        }

        /// <summary>
        /// 生成任务信息(根据出库信息生成作业信息)
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        [ActionName("CreateWorkByStoreOut")]
        [HttpPost]
        public string CreateWorkByStoreOut(WorkByStoreOut obj)
        {
            //出库信息  及 数量及 投入品  作业 配置信息
            DataTable dt_outlist = null;
            //地信息 人员信息 
            DataTable dt_dc = null;
            //任务信息  面积
            DataTable dt_task = null;
            using (dbsimple db = new dbsimple())
            {
                dt_dc = db.Query("select dc.*,(dc.nv1-(SELECT sum(infonv1) from view进行中的任务  ingwork WHERE ingwork.infoid=dc.id GROUP BY infoid) ) as nulldcmj   from yw_baseinfo dc  where dc.id in(" + obj.idbshcrainselectdcinfo.Substring(0, obj.idbshcrainselectdcinfo.Length - 1) + ")");
                var dcids = "";
                foreach (DataRow dr in dt_dc.Rows)
                {
                    dcids += dr["id"].ToString() + ",";
                }
                if (obj.raditworkforwhat == "3")
                {
                    //根据任务
                    dt_task = db.Query("select id,concat(tasksctypename,'-',taskmj,'-',tasksctypename,'-',type,'-',taskno) as name,taskmj,infofv1,infoid from view进行中的任务 where id in(" + obj.idbshcrainselectdcinfo.Substring(0, obj.idbshcrainselectdcinfo.Length - 1) + ")");
                }
                else
                {//根据地块
                    dt_task = db.Query("select id,concat(tasksctypename,'-',taskmj,'-',tasksctypename,'-',type,'-',taskno) as name,taskmj,infofv1,infoid from view进行中的任务 where infoid in(" + dcids.Substring(0, dcids.Length - 1) + ")");
                }

                dt_outlist = db.Query(@"select a.id as outlistid,a.count,a.price,a.unit,a.fromid as inlistid,a.spid,b.`name`,b.remark,
concat(a.spname,'-批次:',a.spbasepc,'-厂家:',a.spbasecj,'-生产日期:',case when a.spbasecdate  is null  then '' else   DATE_FORMAT(a.spbasecdate,'%Y-%m-%d') END  ) as pcinfo,
b.worktypeid,b.worktypename,b.dhmjcount,b.ssbs,b.canoutobj
 
from herp_inoutorderlist a inner join herp_product b on a.spid=b.id where a.ordergid='" + obj.outgid + "'");
            }
            if (dt_outlist.Rows.Count == 0) return "没有投入品不处理";

            if (obj.raditworkforwhat == "1" || obj.raditworkforwhat == "3")
            {
                #region 任务的处理
                double taskallmj = ColumnSum(dt_task, "taskmj");
                foreach (DataRow task in dt_task.Rows)
                {
                    Hashtable allinfo = new Hashtable();
                    var userInfo = (LoginUser)(System.Web.HttpContext.Current.Session["LoginUser"]);
                    if (userInfo != null)
                    {
                        allinfo.Add("fdataadduserid", userInfo.UserId);
                        allinfo.Add("fdatabranchid", userInfo.UserOrg);
                        allinfo.Add("fdatadepid", userInfo.UserDep);
                        allinfo.Add("fdatadepname", userInfo.UserDepName);
                        allinfo.Add("fdatabranchname", userInfo.UserOrgName);
                        allinfo.Add("fdataaddusername", userInfo.UserName);
                        allinfo.Add("fdataaddtime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                    }
                    string erinfo;

                    allinfo.Add("tablename", "hsc_task_info");
                    allinfo.Add("id", "");
                    allinfo.Add("tablemidname", "id");
                    allinfo.Add("finfofv1", task["infofv1"]);//dc_name
                    allinfo.Add("ftaskid", task["id"]);
                    allinfo.Add("finfotypeid", obj.workfinfotypeid);
                    allinfo.Add("finfotypename", obj.workfinfotypename);
                    allinfo.Add("finfotype", obj.workfinfotype);
                    allinfo.Add("finfobytype1", obj.workfinfobytype1);
                    allinfo.Add("finfonv1", task["taskmj"]);
                    allinfo.Add("finfofv4", obj.workfinfofv4);
                    allinfo.Add("finfoid", task["infoid"]);
                    allinfo.Add("fthistaskinfo", task["name"]);
                    allinfo.Add("finfodt1", obj.workfinfodt1);
                    allinfo.Add("finfodt2", obj.workfinfodt2);

                    if (obj.workuserName != "" && obj.workUserId != "")
                    {
                        allinfo.Add("finfofv3", obj.workuserName);
                        allinfo.Add("finfofv2", obj.workUserId);
                    }
                    else
                    {
                        var workuserinfo = getWorkUserbyWorkAndDc(obj.workfinfotype, task["infoid"].ToString());
                        allinfo.Add("finfofv3", workuserinfo[1]);//work username
                        allinfo.Add("finfofv2", workuserinfo[0]);//work useid
                    }
                    allinfo.Add("finfofv5", obj.workfinfofv5);
                    allinfo.Add("finfofv6", obj.workfinfofv6);
                    allinfo.Add("ftjpcount", 0);
                    allinfo.Add("ftjpprice", 0);
                    allinfo.Add("fplantjpcount", 0);
                    allinfo.Add("fplantjpprice", 0);
                    allinfo.Add("finfofv10", obj.workfinfofv10);
                    allinfo.Add("fworktime", 0);
                    allinfo.Add("fworktimeprice", 0);
                    allinfo.Add("finfofv9", "直播");
                    allinfo.Add("finfonv2", 0);//播种量
                    allinfo.Add("finfonv3", 0);//采摘重量
                    allinfo.Add("finfofv11", "待入库");
                    allinfo.Add("fpcgid", obj.outgid);
                    for (int spindex = 0; spindex < dt_outlist.Rows.Count; spindex++)
                    {
                        if (spindex == 0)
                        {
                            allinfo.Add("fzbpid1", dt_outlist.Rows[spindex]["spid"]);
                            allinfo.Add("fzbpname1", dt_outlist.Rows[spindex]["name"]);
                            allinfo.Add("fzbpbs1", dt_outlist.Rows[spindex]["ssbs"]);
                            allinfo.Add("fzbpremark1", dt_outlist.Rows[spindex]["pcinfo"]);
                            allinfo.Add("fzbpdj1", dt_outlist.Rows[spindex]["price"]);
                            allinfo.Add("fzbpunit1", dt_outlist.Rows[spindex]["unit"]);
                            allinfo.Add("fzbppcid1", dt_outlist.Rows[spindex]["inlistid"]);//入库ID
                            allinfo.Add("fzbpyl1", ((double.Parse(dt_outlist.Rows[spindex]["count"].ToString()) * double.Parse(task["taskmj"].ToString())) / taskallmj).ToString("F2"));
                        }
                        if (spindex == 1)
                        {
                            allinfo.Add("fzbpid2", dt_outlist.Rows[spindex]["spid"]);
                            allinfo.Add("fzbpname2", dt_outlist.Rows[spindex]["name"]);
                            allinfo.Add("fzbpbs2", dt_outlist.Rows[spindex]["ssbs"]);
                            allinfo.Add("fzbpremark2", dt_outlist.Rows[spindex]["pcinfo"]);
                            allinfo.Add("fzbpdj2", dt_outlist.Rows[spindex]["price"]);
                            allinfo.Add("fzbpunit2", dt_outlist.Rows[spindex]["unit"]);
                            allinfo.Add("fzbppcid2", dt_outlist.Rows[spindex]["inlistid"]);//入库ID
                            allinfo.Add("fzbpyl2", ((double.Parse(dt_outlist.Rows[spindex]["count"].ToString()) * double.Parse(task["taskmj"].ToString())) / taskallmj).ToString("F2"));
                        }
                        if (spindex == 2)
                        {
                            allinfo.Add("fzbpid3", dt_outlist.Rows[spindex]["spid"]);
                            allinfo.Add("fzbpname3", dt_outlist.Rows[spindex]["name"]);
                            allinfo.Add("fzbpbs3", dt_outlist.Rows[spindex]["ssbs"]);
                            allinfo.Add("fzbpremark3", dt_outlist.Rows[spindex]["pcinfo"]);
                            allinfo.Add("fzbpdj3", dt_outlist.Rows[spindex]["price"]);
                            allinfo.Add("fzbpunit3", dt_outlist.Rows[spindex]["unit"]);
                            allinfo.Add("fzbppcid3", dt_outlist.Rows[spindex]["inlistid"]);//入库ID
                            allinfo.Add("fzbpyl3", ((double.Parse(dt_outlist.Rows[spindex]["count"].ToString()) * double.Parse(task["taskmj"].ToString())) / taskallmj).ToString("F2"));
                        }
                        if (spindex == 3)
                        {
                            allinfo.Add("fzbpid4", dt_outlist.Rows[spindex]["spid"]);
                            allinfo.Add("fzbpname4", dt_outlist.Rows[spindex]["name"]);
                            allinfo.Add("fzbpbs4", dt_outlist.Rows[spindex]["ssbs"]);
                            allinfo.Add("fzbpremark4", dt_outlist.Rows[spindex]["pcinfo"]);
                            allinfo.Add("fzbpdj4", dt_outlist.Rows[spindex]["price"]);
                            allinfo.Add("fzbpunit4", dt_outlist.Rows[spindex]["unit"]);
                            allinfo.Add("fzbppcid4", dt_outlist.Rows[spindex]["inlistid"]);//入库ID
                            allinfo.Add("fzbpyl4", ((double.Parse(dt_outlist.Rows[spindex]["count"].ToString()) * double.Parse(task["taskmj"].ToString())) / taskallmj).ToString("F2"));
                        }
                    }
                    ObjIUD.insertInfo(allinfo, out erinfo);

                }
                #endregion
            }
            else
            {
                string 任务面积的字段 = "nv1";
                if (obj.raditworkforwhat == "2")
                {
                    任务面积的字段 = "nulldcmj";
                }
                double dcallmj = ColumnSum(dt_dc, 任务面积的字段);
                foreach (DataRow dcwork in dt_dc.Rows)
                {
                    Hashtable allinfo = new Hashtable();
                    var userInfo = (LoginUser)(System.Web.HttpContext.Current.Session["LoginUser"]);
                    if (userInfo != null)
                    {
                        allinfo.Add("fdataadduserid", userInfo.UserId);
                        allinfo.Add("fdatabranchid", userInfo.UserOrg);
                        allinfo.Add("fdatadepid", userInfo.UserDep);
                        allinfo.Add("fdatadepname", userInfo.UserDepName);
                        allinfo.Add("fdatabranchname", userInfo.UserOrgName);
                        allinfo.Add("fdataaddusername", userInfo.UserName);
                        allinfo.Add("fdataaddtime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                    }
                    string erinfo;

                    allinfo.Add("tablename", "hsc_task_info");
                    allinfo.Add("id", "");
                    allinfo.Add("tablemidname", "id");
                    allinfo.Add("finfofv1", dcwork["fv1"]);//dc_name
                    allinfo.Add("ftaskid", 0);
                    allinfo.Add("finfotypeid", obj.workfinfotypeid);
                    allinfo.Add("finfotypename", obj.workfinfotypename);
                    allinfo.Add("finfotype", obj.workfinfotype);
                    allinfo.Add("finfobytype1", obj.workfinfobytype1);
                    allinfo.Add("finfonv1", dcwork[任务面积的字段]);
                    allinfo.Add("finfofv4", obj.workfinfofv4);
                    allinfo.Add("finfoid", dcwork["id"]);
                    allinfo.Add("fthistaskinfo", dcwork["fv1"]);
                    allinfo.Add("finfodt1", obj.workfinfodt1);
                    allinfo.Add("finfodt2", obj.workfinfodt2);
                    if (obj.workuserName != "" && obj.workUserId != "")
                    {
                        allinfo.Add("finfofv3", obj.workuserName);
                        allinfo.Add("finfofv2", obj.workUserId);
                    }
                    else
                    {
                        var workuserinfo = getWorkUserbyWorkAndDc(obj.workfinfotype, dcwork["id"].ToString());
                        allinfo.Add("finfofv3", workuserinfo[1]);//work username
                        allinfo.Add("finfofv2", workuserinfo[0]);//work useid
                    }
                    allinfo.Add("finfofv5", obj.workfinfofv5);
                    allinfo.Add("finfofv6", obj.workfinfofv6);
                    allinfo.Add("ftjpcount", 0);
                    allinfo.Add("ftjpprice", 0);
                    allinfo.Add("fplantjpcount", 0);
                    allinfo.Add("fplantjpprice", 0);
                    allinfo.Add("finfofv10", obj.workfinfofv10);
                    allinfo.Add("fworktime", 0);
                    allinfo.Add("fworktimeprice", 0);
                    allinfo.Add("finfofv9", "直播");
                    allinfo.Add("finfonv2", 0);//播种量
                    allinfo.Add("finfonv3", 0);//采摘重量
                    allinfo.Add("finfofv11", "待入库");
                    allinfo.Add("fpcgid", obj.outgid);
                    for (int spindex = 0; spindex < dt_outlist.Rows.Count; spindex++)
                    {
                        if (spindex == 0)
                        {
                            allinfo.Add("fzbpid1", dt_outlist.Rows[spindex]["spid"]);
                            allinfo.Add("fzbpname1", dt_outlist.Rows[spindex]["name"]);
                            allinfo.Add("fzbpbs1", dt_outlist.Rows[spindex]["ssbs"]);
                            allinfo.Add("fzbpremark1", dt_outlist.Rows[spindex]["pcinfo"]);
                            allinfo.Add("fzbpdj1", dt_outlist.Rows[spindex]["price"]);
                            allinfo.Add("fzbpunit1", dt_outlist.Rows[spindex]["unit"]);
                            allinfo.Add("fzbppcid1", dt_outlist.Rows[spindex]["inlistid"]);//入库ID
                            allinfo.Add("fzbpyl1", ((double.Parse(dt_outlist.Rows[spindex]["count"].ToString()) * double.Parse(dcwork[任务面积的字段].ToString())) / dcallmj).ToString("F2"));
                        }
                        if (spindex == 1)
                        {
                            allinfo.Add("fzbpid2", dt_outlist.Rows[spindex]["spid"]);
                            allinfo.Add("fzbpname2", dt_outlist.Rows[spindex]["name"]);
                            allinfo.Add("fzbpbs2", dt_outlist.Rows[spindex]["ssbs"]);
                            allinfo.Add("fzbpremark2", dt_outlist.Rows[spindex]["pcinfo"]);
                            allinfo.Add("fzbpdj2", dt_outlist.Rows[spindex]["price"]);
                            allinfo.Add("fzbpunit2", dt_outlist.Rows[spindex]["unit"]);
                            allinfo.Add("fzbppcid2", dt_outlist.Rows[spindex]["inlistid"]);//入库ID
                            allinfo.Add("fzbpyl2", ((double.Parse(dt_outlist.Rows[spindex]["count"].ToString()) * double.Parse(dcwork[任务面积的字段].ToString())) / dcallmj).ToString("F2"));
                        }
                        if (spindex == 2)
                        {
                            allinfo.Add("fzbpid3", dt_outlist.Rows[spindex]["spid"]);
                            allinfo.Add("fzbpname3", dt_outlist.Rows[spindex]["name"]);
                            allinfo.Add("fzbpbs3", dt_outlist.Rows[spindex]["ssbs"]);
                            allinfo.Add("fzbpremark3", dt_outlist.Rows[spindex]["pcinfo"]);
                            allinfo.Add("fzbpdj3", dt_outlist.Rows[spindex]["price"]);
                            allinfo.Add("fzbpunit3", dt_outlist.Rows[spindex]["unit"]);
                            allinfo.Add("fzbppcid3", dt_outlist.Rows[spindex]["inlistid"]);//入库ID
                            allinfo.Add("fzbpyl3", ((double.Parse(dt_outlist.Rows[spindex]["count"].ToString()) * double.Parse(dcwork[任务面积的字段].ToString())) / dcallmj).ToString("F2"));
                        }
                        if (spindex == 3)
                        {
                            allinfo.Add("fzbpid4", dt_outlist.Rows[spindex]["spid"]);
                            allinfo.Add("fzbpname4", dt_outlist.Rows[spindex]["name"]);
                            allinfo.Add("fzbpbs4", dt_outlist.Rows[spindex]["ssbs"]);
                            allinfo.Add("fzbpremark4", dt_outlist.Rows[spindex]["pcinfo"]);
                            allinfo.Add("fzbpdj4", dt_outlist.Rows[spindex]["price"]);
                            allinfo.Add("fzbpunit4", dt_outlist.Rows[spindex]["unit"]);
                            allinfo.Add("fzbppcid4", dt_outlist.Rows[spindex]["inlistid"]);//入库ID
                            allinfo.Add("fzbpyl4", ((double.Parse(dt_outlist.Rows[spindex]["count"].ToString()) * double.Parse(dcwork[任务面积的字段].ToString())) / dcallmj).ToString("F2"));
                        }
                    }
                    ObjIUD.insertInfo(allinfo, out erinfo);

                }
            }

            //          `zbpid1` bigint(20) DEFAULT NULL COMMENT '植保品ID',
            //`zbpname1` varchar(100) DEFAULT NULL COMMENT '植保品名称1',
            //`zbpbs1` double(10,2) DEFAULT NULL COMMENT '植保品稀释倍数',
            //`zbpremark1` varchar(200) DEFAULT NULL COMMENT '说明',
            //`zbppcid1` varchar(100) DEFAULT NULL COMMENT '植保品批次号',
            //`zbpyl1` double(10,2) DEFAULT NULL COMMENT '原料量',

            //           `zbpdj1` double(10,2) DEFAULT NULL COMMENT '单价',
            //`zbpunit1` varchar(100) DEFAULT NULL COMMENT '单位1',






            return "1111";
        }

        double ColumnSum(DataTable dt, string ColumnName)
        {
            double d = 0;
            foreach (DataRow row in dt.Rows)
            {
                var infostring = row[ColumnName].ToString();
                if (string.IsNullOrEmpty(infostring)) infostring = "0";
                d += double.Parse(infostring);
            }
            return d;
        }

        /// <summary>
        /// 根据地块及作业类型找作业人员
        /// </summary>
        /// <param name="worktypenum"></param>
        /// <param name="workdcid"></param>
        /// <returns></returns>
        public string[] getWorkUserbyWorkAndDc(string worktypenum, string workdcid)
        {
            string[] reinfo = new string[] { "", "" };
            DataTable dt_dc = null;
            using (dbsimple db = new dbsimple())
            {
                dt_dc = db.Query("select * from yw_baseinfo where id =" + workdcid);
            }
            if (dt_dc.Rows.Count == 0) return reinfo;

            var workuserid = "";
            if (worktypenum == "3")
            {//作业人员ID
                workuserid = dt_dc.Rows[0]["fv11"].ToString();
            }
            else if (worktypenum == "4")
            {
                workuserid = dt_dc.Rows[0]["fv13"].ToString();
            }
            else if (worktypenum == "5")
            {
                workuserid = dt_dc.Rows[0]["fv12"].ToString();
            }
            else if (worktypenum == "6")
            {
                workuserid = dt_dc.Rows[0]["fv17"].ToString();
            }
            else if (worktypenum == "7")
            {
                workuserid = dt_dc.Rows[0]["fv14"].ToString();
            }
            else if (worktypenum == "8")
            {
                workuserid = dt_dc.Rows[0]["fv15"].ToString();
            }
            else if (worktypenum == "9")
            {
                workuserid = dt_dc.Rows[0]["fv18"].ToString();
            }
            else if (worktypenum == "10")
            {
                workuserid = dt_dc.Rows[0]["fv16"].ToString();
            }
            else if (worktypenum == "11")
            {
                workuserid = dt_dc.Rows[0]["fv19"].ToString();
            }
            else if (worktypenum == "12")
            {
                workuserid = dt_dc.Rows[0]["fv20"].ToString();
            }
            else if (worktypenum == "13")
            {
                workuserid = dt_dc.Rows[0]["fv21"].ToString();
            }
            if (!string.IsNullOrEmpty(workuserid))
            {
                reinfo[0] = workuserid;
                reinfo[1] = workuserid;
                using (dbsimple db = new dbsimple())
                {
                    var d = db.Query("select empname from view_user where empid =" + workuserid);
                    if (d.Rows.Count > 0)
                    {
                        reinfo[1] = d.Rows[0][0].ToString();
                    }
                }
            }
            return reinfo;
        }

        [ActionName("GetWorkAllInfoToEndByTaskId")]
        [HttpGet]
        /// <summary>
        /// 根据 任务ID 获取 生产基地农事记录表 所有信息 发货信息  中心信息
        /// </summary>
        /// <param name="taskordcid"></param>
        /// <param name="includedk">是否包括地块的任务</param>
        /// <param name="includeCenter">是否包括深圳加工中心的记录</param>
        ///  <param name="infodt1start infodt1end">当是查询地块上的作业时  作业的时间段</param>
        ///  <param name="noworkstarttimes noworkstarttimee">采收 加工 帖码 发货 等 生产的时间段</param>
        /// <returns></returns>
        public string GetWorkAllInfoToEndByTaskId(string taskordcid, bool includedk = false, string infodt1start = "",
            string infodt1end = "", bool includeCenter = false, string noworkstarttimes = "", string noworkstarttimee = "")
        {
            string 采收加工帖码发货等生产的时间段 = " and 1=1 ";
            if (!string.IsNullOrEmpty(noworkstarttimes))
            { 采收加工帖码发货等生产的时间段 += " and dataaddtime >= '" + noworkstarttimes + "' "; }
            if (!string.IsNullOrEmpty(noworkstarttimee))
            { 采收加工帖码发货等生产的时间段 += " and dataaddtime <= '" + noworkstarttimee + "' "; }

            DataTable dt_task = null;//基本信息
            DataTable dt_taskwork = null;//任务的作业
            DataTable dt_dcwork = null;//最近的地作业
            DataTable dt_taskGet = null;//采摘
            using (dbsimple db = new dbsimple())
            {
                string taskendtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                if (string.IsNullOrEmpty(infodt1start))//代表是任务的查询-找主任务
                {
                    dt_task = db.Query(@"SELECT a.*,b.fv1 as dcname,b.fv8 dctype,b.nv1 dcmj  
from hsc_task a INNER JOIN  yw_baseinfo b on a.maindcid=b.id
where a.id=" + taskordcid);

                    if (dt_task.Rows.Count > 0 && dt_task.Rows[0]["taskstatus"].ToString() == "完成")
                    {
                        //找完成时间
                        var endtaskwork = db.Query(@"SELECT infodt1 from hsc_task_info where taskid=" + taskordcid + " and infotype=13");
                        taskendtime = endtaskwork.Rows[0]["infodt1"].ToString();
                    }
                }
                if (includedk)
                {
                    if (string.IsNullOrEmpty(infodt1start))//代表是任务的查询-作业
                    {
                        //任务上和地块上对应时间上的
                        dt_taskwork = db.Query(string.Format(@"SELECT *,(SELECT  CONCAT( fv3,'-',fv4 )from yw_baseinfo where id=w.infofv5 ) as worktoolname
            ,(SELECT producttype from herp_product where id=w.zbpid1)  as zbptype1
            ,(SELECT producttype from herp_product where id=w.zbpid2)  as zbptype2
            ,(SELECT producttype from herp_product where id=w.zbpid3)  as zbptype3
            ,(SELECT producttype from herp_product where id=w.zbpid4)  as zbptype4
            from viewtask_allltask w 
            where   (  w.taskid={0}  and infotype!= 1  and infotype!= 11) " +
                       " or ( w.areadcid={1}  and infodt1  <='{2}' and infodt1 >= '{3}' and w.taskid=0)",
                       taskordcid,
                       dt_task.Rows[0]["maindcid"].ToString(),
                       taskendtime,
                       dt_task.Rows[0]["taskstarttime"].ToString()));
                        //( w.areadcid=1033 and w.taskid=0 )
                    }
                    else//代表是地块的查询
                    {
                        dt_taskwork = db.Query(string.Format(@"SELECT *,(SELECT  CONCAT( fv3,'-',fv4 )from yw_baseinfo where id=w.infofv5 ) as worktoolname
            ,(SELECT producttype from herp_product where id=w.zbpid1)  as zbptype1
            ,(SELECT producttype from herp_product where id=w.zbpid2)  as zbptype2
            ,(SELECT producttype from herp_product where id=w.zbpid3)  as zbptype3
            ,(SELECT producttype from herp_product where id=w.zbpid4)  as zbptype4
            from viewtask_allltask w 
            where ( w.areadcid={0}  and infodt1  <='{1}' and infodt1 >= '{2}')",
           taskordcid, infodt1end, infodt1start));
                    }
                }
                else
                {
                    //任务上的作业
                    dt_taskwork = db.Query(@"SELECT *,(SELECT  CONCAT( fv3,'-',fv4 )from yw_baseinfo where id=w.infofv5 ) as worktoolname
            ,(SELECT producttype from herp_product where id=w.zbpid1)  as zbptype1
            ,(SELECT producttype from herp_product where id=w.zbpid2)  as zbptype2
            ,(SELECT producttype from herp_product where id=w.zbpid3)  as zbptype3
            ,(SELECT producttype from herp_product where id=w.zbpid4)  as zbptype4
            from viewtask_allltask w 
            where w.taskid=" + taskordcid + "  and infotype!= 1  and infotype!= 11");
                }
                if (string.IsNullOrEmpty(infodt1start))//代表是任务的查询-早于任务的 地块的 三大任务 补充
                {
                    //早于任务的 地块的 三大任务 补充
                    dt_dcwork = db.Query(string.Format(@" SELECT * ,(SELECT  CONCAT( fv3,'-',fv4 )from yw_baseinfo where id=w.infofv5 ) as worktoolname
            ,(SELECT producttype from herp_product where id=w.zbpid1)  as zbptype1
            ,(SELECT producttype from herp_product where id=w.zbpid2)  as zbptype2
            ,(SELECT producttype from herp_product where id=w.zbpid3)  as zbptype3
            ,(SELECT producttype from herp_product where id=w.zbpid4)  as zbptype4
             from viewtask_allltask w 
            where w.listid =(SELECT  id from hsc_task_info where infoid={0} and taskid= 0 and infotype =3  and infodt1<='{1}' ORDER BY infodt1 desc  LIMIT 0,1)
            UNION 
            SELECT * ,(SELECT  CONCAT( fv3,'-',fv4 )from yw_baseinfo where id=w.infofv5 ) as worktoolname 
            ,(SELECT producttype from herp_product where id=w.zbpid1)  as zbptype1
            ,(SELECT producttype from herp_product where id=w.zbpid2)  as zbptype2
            ,(SELECT producttype from herp_product where id=w.zbpid3)  as zbptype3
            ,(SELECT producttype from herp_product where id=w.zbpid4)  as zbptype4
            from viewtask_allltask w 
            where w.listid =(SELECT  id from hsc_task_info where infoid={0} and taskid= 0 and infotype =4 and infodt1<='{1}' ORDER BY infodt1 desc  LIMIT 0,1)
            UNION  
            SELECT * ,(SELECT  CONCAT( fv3,'-',fv4 )from yw_baseinfo where id=w.infofv5 ) as worktoolname 
            ,(SELECT producttype from herp_product where id=w.zbpid1)  as zbptype1
            ,(SELECT producttype from herp_product where id=w.zbpid2)  as zbptype2
            ,(SELECT producttype from herp_product where id=w.zbpid3)  as zbptype3
            ,(SELECT producttype from herp_product where id=w.zbpid4)  as zbptype4
            from viewtask_allltask w 
            where w.listid =(SELECT  id from hsc_task_info where infoid={0} and taskid= 0 and infotype =5 and infodt1<='{1}' ORDER BY infodt1 desc  LIMIT 0,1)",
                dt_task.Rows[0]["maindcid"].ToString(),
                dt_task.Rows[0]["taskstarttime"].ToString()));

                    //采收信息
                    dt_taskGet = db.Query(@"SELECT *,(SELECT  CONCAT( fv3,'-',fv4 )from yw_baseinfo where id=w.infofv5 ) as worktoolname
            ,(SELECT producttype from herp_product where id=w.zbpid1)  as zbptype1
            ,(SELECT producttype from herp_product where id=w.zbpid2)  as zbptype2
            ,(SELECT producttype from herp_product where id=w.zbpid3)  as zbptype3
            ,(SELECT producttype from herp_product where id=w.zbpid4)  as zbptype4
            from viewtask_allltask w 
            where w.taskid=" + taskordcid + "  and infotype= 11" + 采收加工帖码发货等生产的时间段);
                }
                //  " SELECT * from hsc_task_store where taskid=" + taskid + " Order by dataaddtime ");
            }
            //	infofv10	checked,	checked,1049,1249,		SELECT  * from yw_baseinfo where id in(1049,1249)				取防治对象												
            if (dt_dcwork != null && dt_dcwork.Rows.Count > 0) foreach (DataRow dr in dt_dcwork.Rows)
                {
                    dr["infofv10"] = dr["infofv10"].ToString().Replace("checked,", "").Replace("checked", "");
                }
            using (dbsimple db = new dbsimple())
            {
                if (dt_taskwork != null && dt_taskwork.Rows.Count > 0) foreach (DataRow dr in dt_taskwork.Rows)
                    {
                        if (dr["infotype"].ToString() == "8" && dr["infofv10"].ToString().Length > 8)
                        {
                            var dtfjds = db.Query(@"SELECT  fv1 from yw_baseinfo where id in(" + (dr["infofv10"].ToString().Substring(0, dr["infofv10"].ToString().Length - 1)).Replace("checked,", "").Replace("checked", "") + ")");
                            var fj = "";
                            foreach (DataRow dt1 in dtfjds.Rows)
                            {
                                fj += dt1[0].ToString() + "/";

                            }
                            dr["infofv10"] = fj.EndsWith("/") ? fj.Substring(0, fj.Length - 1) : fj;
                        }
                        else
                        { dr["infofv10"] = dr["infofv10"].ToString().Replace("checked,", "").Replace("checked", ""); }
                    }
            }
            #region 加工中心的记录
            string 自加工出库 = "[]";
            string 自加工入库采摘加工入库 = "[]";
            string 基地库出库运输 = "[]";
            string 批次中心库运输入库 = "[]";
            string 批次中心库取料加工 = "[]";
            string 批次中心库取料加工完成及半成品进入待发库 = "[]";
            string 中心库贴码信息 = "[]";
            string 批次发贷信息 = "[]";
            DataTable dt_自加工出库 = new DataTable();
            DataTable dt_自加工入库 = new DataTable();
            DataTable dt_基地库出库运输 = new DataTable();
            DataTable dt_中心库运输入库 = new DataTable();
            DataTable dt_取原料 = new DataTable();
            DataTable 中心加工完成入库 = new DataTable();
            DataTable dt_发到商超 = new DataTable();
            DataTable dt_贴码记录信息 = new DataTable();
            if (includeCenter)
            {
                using (dbsimple db = new dbsimple())
                {
                    //5自加工出库
                    dt_自加工出库 = db.Query(string.Format("SELECT * from hsc_task_process_work where taskid={0} and inouttype='自加工出库' " + 采收加工帖码发货等生产的时间段, taskordcid));
                    自加工出库 = JsonControl.GetJsonStr(dt_自加工出库);

                    //6自加工入库 采摘加工入库
                    dt_自加工入库 = db.Query(string.Format("SELECT * from hsc_task_store where taskid={0} and inouttype in('加工完成入库','采摘加工入库') " + 采收加工帖码发货等生产的时间段, taskordcid));
                    自加工入库采摘加工入库 = JsonControl.GetJsonStr(dt_自加工入库);


                    ////7所有相关库存
                    //DataTable dt_基地库 = db.Query(string.Format("SELECT * from hsc_task_store where taskid={0} ", taskordcid));

                    string Ids = "";


                    //8基地库出库运输
                    dt_基地库出库运输 = db.Query(string.Format("SELECT * from hsc_task_store_out where taskid={0} " + 采收加工帖码发货等生产的时间段, taskordcid));
                    基地库出库运输 = JsonControl.GetJsonStr(dt_基地库出库运输);


                    Ids = "";
                    foreach (DataRow row in dt_基地库出库运输.Rows)
                    {
                        if (!string.IsNullOrEmpty(row["centeringuid"].ToString()))
                        {
                            Ids += "'" + row["centeringuid"] + "',";
                        }
                    }
                    if (Ids.Length >= 2)
                    {
                        Ids = Ids.Substring(0, Ids.Length - 1);
                    }
                    else
                        Ids = "'0'";

                    //9中心入库 批次（不是真实信息，批次汇总信息）
                    dt_中心库运输入库 = db.Query(string.Format("SELECT * from hsc_task_store_process where   outgid in ({0}) and productid={1} and taskfromorgid={2} " + 采收加工帖码发货等生产的时间段, Ids, dt_task.Rows[0]["tasksctype"].ToString(), dt_task.Rows[0]["databranchid"].ToString()));
                    批次中心库运输入库 = JsonControl.GetJsonStr(dt_中心库运输入库);


                    Ids = "";
                    foreach (DataRow row in dt_中心库运输入库.Rows)
                    {
                        Ids += row["id"] + ",";
                    }
                    if (Ids.Length >= 2)
                    {
                        Ids = Ids.Substring(0, Ids.Length - 1);
                    }
                    else
                        Ids = "0";
                    var 直接到帖码的ID = Ids;

                    //10中心出库加工
                    dt_取原料 = db.Query(string.Format("SELECT * from hsc_task_process_work where taskid ={0} and inouttype='出库加工'" + 采收加工帖码发货等生产的时间段, taskordcid));
                    批次中心库取料加工 = JsonControl.GetJsonStr(dt_取原料);


                    Ids = "";
                    foreach (DataRow row in dt_取原料.Rows)
                    {
                        Ids += row["id"] + ",";
                    }
                    if (Ids.Length >= 2)
                    {
                        Ids = Ids.Substring(0, Ids.Length - 1);
                    }
                    else
                        Ids = "0";



                    ////10中心加工完成入库
                    中心加工完成入库 = db.Query(string.Format("SELECT * from hsc_task_process_workok  where ( datafromkeyid in({0}) or (datafromtable='hsc_task_store_process' and datafromkeyid in({1})) )" + 采收加工帖码发货等生产的时间段, Ids, 直接到帖码的ID));
                    批次中心库取料加工完成及半成品进入待发库 = JsonControl.GetJsonStr(中心加工完成入库);



                    Ids = "";
                    foreach (DataRow row in 中心加工完成入库.Rows)
                    {
                        Ids += row["id"] + ",";
                    }
                    if (Ids.Length >= 2)
                    {
                        Ids = Ids.Substring(0, Ids.Length - 1);
                    }
                    else
                        Ids = "0";

                    //12发到商超
                    dt_发到商超 = db.Query(string.Format("SELECT * from hsc_task_process_workokout where datafromkeyid in({0}) " + 采收加工帖码发货等生产的时间段 + " order by dataaddtime desc", Ids));
                    批次发贷信息 = JsonControl.GetJsonStr(dt_发到商超);




                    dt_贴码记录信息 = db.Query(string.Format("SELECT * from hsc_task_process_workok_code  where taskid ={0} " + 采收加工帖码发货等生产的时间段, taskordcid));
                    中心库贴码信息 = JsonControl.GetJsonStr(dt_贴码记录信息);
                    //string 批次发贷库信息 = "";

                }
            }
            #endregion
            var task = JsonControl.GetJsonStr(dt_task);
            var taskwork = JsonControl.GetJsonStr(dt_taskwork);
            var dcwork = JsonControl.GetJsonStr(dt_dcwork);
            var taskGet = JsonControl.GetJsonStr(dt_taskGet);





            var reinfo = "{\"task\":" + task + ",\"taskwork\":" + taskwork + ",\"dcwork\":" + dcwork +
                ",\"taskGet\":" + taskGet
                 + ",\"seftjgout\":" + 自加工出库
                  + ",\"seftjgend\":" + 自加工入库采摘加工入库
                   + ",\"sefttocenter\":" + 基地库出库运输
                    + ",\"pccenterin\":" + 批次中心库运输入库
                     + ",\"pccenterjgout\":" + 批次中心库取料加工
                      + ",\"pccenterjgend\":" + 批次中心库取料加工完成及半成品进入待发库
                       + ",\"taskcodeinfo\":" + 中心库贴码信息
                        + ",\"pccenterouttoend\":" + 批次发贷信息
                + "}";

            return reinfo;

        }



        [ActionName("GetWorkAllInfoToEndByTaskIdNew")]
        [HttpGet]
        /// <summary>
        /// 根据 任务ID 获取 生产基地农事记录表 所有信息 发货信息  中心信息
        /// </summary>
        /// <param name="taskordcid"></param>
        /// <param name="includedk">是否包括地块的任务</param>
        /// <param name="includeCenter">是否包括深圳加工中心的记录</param>
        ///  <param name="infodt1start infodt1end">当是查询地块上的作业时  作业的时间段</param>
        ///  <param name="noworkstarttimes noworkstarttimee">采收 加工 帖码 发货 等 生产的时间段</param>
        /// <returns></returns>
        public string GetWorkAllInfoToEndByTaskIdNew(string taskordcid, bool includedk = false, string infodt1start = "",
            string infodt1end = "", bool includeCenter = false, string noworkstarttimes = "", string noworkstarttimee = "")
        {
            string 采收加工帖码发货等生产的时间段 = " and 1=1 ";
            if (!string.IsNullOrEmpty(noworkstarttimes))
            { 采收加工帖码发货等生产的时间段 += " and dataaddtime >= '" + noworkstarttimes + "' "; }
            if (!string.IsNullOrEmpty(noworkstarttimee))
            { 采收加工帖码发货等生产的时间段 += " and dataaddtime <= '" + noworkstarttimee + "' "; }

            DataTable dt_task = null;//基本信息
            DataTable dt_taskwork = null;//任务的作业
            DataTable dt_dcwork = null;//最近的地作业
            DataTable dt_taskGet = null;//采摘
            using (dbsimple db = new dbsimple())
            {
                string taskendtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                if (string.IsNullOrEmpty(infodt1start))//代表是任务的查询-找主任务
                {
                    dt_task = db.Query(@"SELECT a.*,b.fv1 as dcname,b.fv8 dctype,b.nv1 dcmj,c.zzsourepc as jmzzsourepc  
from hsc_task a INNER JOIN  yw_baseinfo b on a.maindcid=b.id left join hsc_task c on a.ymid=c.id
where a.id=" + taskordcid);

                    if (dt_task.Rows.Count > 0 && dt_task.Rows[0]["taskstatus"].ToString() == "完成")
                    {
                        //找完成时间
                        var endtaskwork = db.Query(@"SELECT infodt1 from hsc_task_info where taskid=" + taskordcid + " and infotype=13");
                        taskendtime = endtaskwork.Rows[0]["infodt1"].ToString();
                    }
                }
                if (includedk)
                {
                    if (string.IsNullOrEmpty(infodt1start))//代表是任务的查询-作业
                    {
                        //任务上和地块上对应时间上的
                        dt_taskwork = db.Query(string.Format(@"SELECT *,(SELECT  CONCAT( fv3,'-',fv4 )from yw_baseinfo where id=w.infofv5 ) as worktoolname
            ,(SELECT producttype from herp_product where id=w.zbpid1)  as zbptype1
            ,(SELECT producttype from herp_product where id=w.zbpid2)  as zbptype2
            ,(SELECT producttype from herp_product where id=w.zbpid3)  as zbptype3
            ,(SELECT producttype from herp_product where id=w.zbpid4)  as zbptype4
            from viewtask_allltask w 
            where   (  w.taskid={0}  and infotype!= 1  and infotype!= 11) " +

                       @" UNION  SELECT *,(SELECT  CONCAT( fv3,'-',fv4 )from yw_baseinfo where id=w.infofv5 ) as worktoolname
            ,(SELECT producttype from herp_product where id=w.zbpid1)  as zbptype1
            ,(SELECT producttype from herp_product where id=w.zbpid2)  as zbptype2
            ,(SELECT producttype from herp_product where id=w.zbpid3)  as zbptype3
            ,(SELECT producttype from herp_product where id=w.zbpid4)  as zbptype4
            from viewtask_allltask w 
            where   ( w.areadcid={1}  and infodt1  <='{2}' and infodt1 >= '{3}' and w.taskid=0)",
                       taskordcid,
                       dt_task.Rows[0]["maindcid"].ToString(),
                       taskendtime,
                       dt_task.Rows[0]["taskstarttime"].ToString()));
                        //( w.areadcid=1033 and w.taskid=0 )
                    }
                    else//代表是地块的查询
                    {
                        dt_taskwork = db.Query(string.Format(@"SELECT *,(SELECT  CONCAT( fv3,'-',fv4 )from yw_baseinfo where id=w.infofv5 ) as worktoolname
            ,(SELECT producttype from herp_product where id=w.zbpid1)  as zbptype1
            ,(SELECT producttype from herp_product where id=w.zbpid2)  as zbptype2
            ,(SELECT producttype from herp_product where id=w.zbpid3)  as zbptype3
            ,(SELECT producttype from herp_product where id=w.zbpid4)  as zbptype4
            from viewtask_allltask w 
            where ( w.areadcid={0}  and infodt1  <='{1}' and infodt1 >= '{2}')",
           taskordcid, infodt1end, infodt1start));
                    }
                }
                else
                {
                    //任务上的作业
                    dt_taskwork = db.Query(@"SELECT *,(SELECT  CONCAT( fv3,'-',fv4 )from yw_baseinfo where id=w.infofv5 ) as worktoolname
            ,(SELECT producttype from herp_product where id=w.zbpid1)  as zbptype1
            ,(SELECT producttype from herp_product where id=w.zbpid2)  as zbptype2
            ,(SELECT producttype from herp_product where id=w.zbpid3)  as zbptype3
            ,(SELECT producttype from herp_product where id=w.zbpid4)  as zbptype4
            from viewtask_allltask w 
            where w.taskid=" + taskordcid + "  and infotype!= 1  and infotype!= 11");
                }
                if (string.IsNullOrEmpty(infodt1start))//代表是任务的查询-早于任务的 地块的 三大任务 补充
                {
                    //早于任务的 地块的 三大任务 补充
                    dt_dcwork = db.Query(string.Format(@" SELECT * ,(SELECT  CONCAT( fv3,'-',fv4 )from yw_baseinfo where id=w.infofv5 ) as worktoolname
            ,(SELECT producttype from herp_product where id=w.zbpid1)  as zbptype1
            ,(SELECT producttype from herp_product where id=w.zbpid2)  as zbptype2
            ,(SELECT producttype from herp_product where id=w.zbpid3)  as zbptype3
            ,(SELECT producttype from herp_product where id=w.zbpid4)  as zbptype4
             from viewtask_allltask w 
            where w.listid =(SELECT  id from hsc_task_info where infoid={0} and taskid= 0 and infotype =3  and infodt1<='{1}' ORDER BY infodt1 desc  LIMIT 0,1)
            UNION 
            SELECT * ,(SELECT  CONCAT( fv3,'-',fv4 )from yw_baseinfo where id=w.infofv5 ) as worktoolname 
            ,(SELECT producttype from herp_product where id=w.zbpid1)  as zbptype1
            ,(SELECT producttype from herp_product where id=w.zbpid2)  as zbptype2
            ,(SELECT producttype from herp_product where id=w.zbpid3)  as zbptype3
            ,(SELECT producttype from herp_product where id=w.zbpid4)  as zbptype4
            from viewtask_allltask w 
            where w.listid =(SELECT  id from hsc_task_info where infoid={0} and taskid= 0 and infotype =4 and infodt1<='{1}' ORDER BY infodt1 desc  LIMIT 0,1)
            UNION  
            SELECT * ,(SELECT  CONCAT( fv3,'-',fv4 )from yw_baseinfo where id=w.infofv5 ) as worktoolname 
            ,(SELECT producttype from herp_product where id=w.zbpid1)  as zbptype1
            ,(SELECT producttype from herp_product where id=w.zbpid2)  as zbptype2
            ,(SELECT producttype from herp_product where id=w.zbpid3)  as zbptype3
            ,(SELECT producttype from herp_product where id=w.zbpid4)  as zbptype4
            from viewtask_allltask w 
            where w.listid =(SELECT  id from hsc_task_info where infoid={0} and taskid= 0 and infotype =5 and infodt1<='{1}' ORDER BY infodt1 desc  LIMIT 0,1)",
                dt_task.Rows[0]["maindcid"].ToString(),
                dt_task.Rows[0]["taskstarttime"].ToString()));

                    //采收信息
                    dt_taskGet = db.Query(@"SELECT *,(SELECT  CONCAT( fv3,'-',fv4 )from yw_baseinfo where id=w.infofv5 ) as worktoolname
            ,(SELECT producttype from herp_product where id=w.zbpid1)  as zbptype1
            ,(SELECT producttype from herp_product where id=w.zbpid2)  as zbptype2
            ,(SELECT producttype from herp_product where id=w.zbpid3)  as zbptype3
            ,(SELECT producttype from herp_product where id=w.zbpid4)  as zbptype4
            from viewtask_allltask w 
            where w.taskid=" + taskordcid + "  and infotype= 11" + 采收加工帖码发货等生产的时间段);
                }
                //  " SELECT * from hsc_task_store where taskid=" + taskid + " Order by dataaddtime ");
            }
            //	infofv10	checked,	checked,1049,1249,		SELECT  * from yw_baseinfo where id in(1049,1249)				取防治对象												
            if (dt_dcwork != null && dt_dcwork.Rows.Count > 0) foreach (DataRow dr in dt_dcwork.Rows)
                {
                    dr["infofv10"] = dr["infofv10"].ToString().Replace("checked,", "").Replace("checked", "");
                }
            using (dbsimple db = new dbsimple())
            {
                if (dt_taskwork != null && dt_taskwork.Rows.Count > 0) foreach (DataRow dr in dt_taskwork.Rows)
                    {
                        if (dr["infotype"].ToString() == "8" && dr["infofv10"].ToString().Length > 8)
                        {
                            var dtfjds = db.Query(@"SELECT  fv1 from yw_baseinfo where id in(" + (dr["infofv10"].ToString().Substring(0, dr["infofv10"].ToString().Length - 1)).Replace("checked,", "").Replace("checked", "") + ")");
                            var fj = "";
                            foreach (DataRow dt1 in dtfjds.Rows)
                            {
                                fj += dt1[0].ToString() + "/";

                            }
                            dr["infofv10"] = fj.EndsWith("/") ? fj.Substring(0, fj.Length - 1) : fj;
                        }
                        else
                        { dr["infofv10"] = dr["infofv10"].ToString().Replace("checked,", "").Replace("checked", ""); }
                    }
            }
            #region 加工中心的记录

            DataTable dt_自加工出库 = new DataTable();
            DataTable dt_自加工入库 = new DataTable();
            DataTable dt_基地库出库运输 = new DataTable();
            DataTable dt_中心库运输入库 = new DataTable();
            DataTable dt_取原料 = new DataTable();
            DataTable 中心加工完成入库 = new DataTable();
            DataTable dt_发到商超 = new DataTable();
            DataTable dt_贴码记录信息 = new DataTable();
            if (includeCenter)
            {
                using (dbsimple db = new dbsimple())
                {
                    //5自加工出库
                    dt_自加工出库 = db.Query(string.Format("SELECT * from hsc_task_process_work where taskid={0} and inouttype='自加工出库' " + 采收加工帖码发货等生产的时间段, taskordcid));

                    //6自加工入库 采摘加工入库
                    dt_自加工入库 = db.Query(string.Format("SELECT * from hsc_task_store where taskid={0} and inouttype in('加工完成入库','采摘加工入库') " + 采收加工帖码发货等生产的时间段, taskordcid));


                    ////7所有相关库存
                    //DataTable dt_基地库 = db.Query(string.Format("SELECT * from hsc_task_store where taskid={0} ", taskordcid));

                    string Ids = "";


                    //8基地库出库运输
                    dt_基地库出库运输 = db.Query(string.Format("SELECT * from hsc_task_store_out where taskid={0} " + 采收加工帖码发货等生产的时间段, taskordcid));


                    Ids = "";
                    foreach (DataRow row in dt_基地库出库运输.Rows)
                    {
                        if (!string.IsNullOrEmpty(row["centeringuid"].ToString()))
                        {
                            Ids += "'" + row["centeringuid"] + "',";
                        }
                    }
                    if (Ids.Length >= 2)
                    {
                        Ids = Ids.Substring(0, Ids.Length - 1);
                    }
                    else
                        Ids = "'0'";

                    //9中心入库 批次（不是真实信息，批次汇总信息）
                    dt_中心库运输入库 = db.Query(string.Format("SELECT * from hsc_task_store_process where   outgid in ({0}) and productid={1} and taskfromorgid={2} " + 采收加工帖码发货等生产的时间段, Ids, dt_task.Rows[0]["tasksctype"].ToString(), dt_task.Rows[0]["databranchid"].ToString()));


                    Ids = "";
                    foreach (DataRow row in dt_中心库运输入库.Rows)
                    {
                        Ids += row["id"] + ",";
                    }
                    if (Ids.Length >= 2)
                    {
                        Ids = Ids.Substring(0, Ids.Length - 1);
                    }
                    else
                        Ids = "0";
                    var 直接到帖码的ID = Ids;

                    //10中心出库加工
                    dt_取原料 = db.Query(string.Format("SELECT * from hsc_task_process_work where taskid ={0} and inouttype='出库加工'" + 采收加工帖码发货等生产的时间段, taskordcid));


                    Ids = "";
                    foreach (DataRow row in dt_取原料.Rows)
                    {
                        Ids += row["id"] + ",";
                    }
                    if (Ids.Length >= 2)
                    {
                        Ids = Ids.Substring(0, Ids.Length - 1);
                    }
                    else
                        Ids = "0";



                    ////10中心加工完成入库
                    中心加工完成入库 = db.Query(string.Format("SELECT * from hsc_task_process_workok  where ( datafromkeyid in({0}) or (datafromtable='hsc_task_store_process' and datafromkeyid in({1})) )" + 采收加工帖码发货等生产的时间段, Ids, 直接到帖码的ID));



                    Ids = "";
                    foreach (DataRow row in 中心加工完成入库.Rows)
                    {
                        Ids += row["id"] + ",";
                    }
                    if (Ids.Length >= 2)
                    {
                        Ids = Ids.Substring(0, Ids.Length - 1);
                    }
                    else
                        Ids = "0";

                    //12发到商超
                    dt_发到商超 = db.Query(string.Format("SELECT * from hsc_task_process_workokout where datafromkeyid in({0}) " + 采收加工帖码发货等生产的时间段 + " order by dataaddtime desc", Ids));




                    dt_贴码记录信息 = db.Query(string.Format("SELECT * from hsc_task_process_workok_code  where taskid ={0} " + 采收加工帖码发货等生产的时间段, taskordcid));
                    //string 批次发贷库信息 = "";

                }
            }
            #endregion
            var task = JsonControl.GetJsonStr(dt_task);




            var alls = new List<showinfoall>();
            if (dt_dcwork != null) foreach (DataRow dr in dt_dcwork.Rows)//地作业
                {
                    alls.Add(new showinfoall
                    {
                        worktfl = "dcwork",
                        worktime2 = DateTime.Parse(dr["infodt1"].ToString()),
                        dayTctype = dr["infofv4"].ToString(),
                        worktype = dr["listinfoname"].ToString(),
                        worktoolname = dr["worktoolname"].ToString(),
                        workfjobj = dr["infofv10"].ToString(),
                        zbptype1 = dr["zbptype1"].ToString(),
                        zbpname1 = dr["zbpname1"].ToString(),
                        zbpbs1 = dr["zbpbs1"].ToString(),
                        zbpremark1 = dr["zbpremark1"].ToString(),
                        zbpyl1 = dr["zbpyl1"].ToString(),
                        infofv3 = dr["infofv3"].ToString(),
                        infofv6 = dr["infofv6"].ToString(),
                        zbpunit1 = dr["zbpunit1"].ToString(),
                        zbpunit2 = dr["zbpunit2"].ToString(),
                        zbpunit3 = dr["zbpunit3"].ToString(),
                        zbpunit4 = dr["zbpunit4"].ToString(),

                    });
                }
            foreach (DataRow dr in dt_taskwork.Rows)//任务作业
            {

                if ("底肥打地整地".IndexOf(dr["listinfoname"].ToString()) >= 0)
                { //如果之前有地块的 不要地块的了，用任务的
                    alls.RemoveAll(m => m.worktype == dr["listinfoname"].ToString() && m.worktfl == "dcwork");
                    //如果之前有任务对应的了，使用之前的
                    if (alls.Any(m => m.worktype == dr["listinfoname"].ToString())) continue;
                }


                alls.Add(new showinfoall
                {
                    worktfl = "taskwork",
                    worktime2 = DateTime.Parse(dr["infodt1"].ToString()),
                    dayTctype = dr["infofv4"].ToString(),
                    worktype = dr["listinfoname"].ToString(),
                    worktoolname = dr["worktoolname"].ToString(),
                    workfjobj = dr["infofv10"].ToString(),

                    zbptype2 = dr["zbptype2"].ToString(),
                    zbptype3 = dr["zbptype3"].ToString(),
                    zbptype4 = dr["zbptype4"].ToString(),
                    zbpbs2 = dr["zbpbs2"].ToString(),
                    zbpbs3 = dr["zbpbs3"].ToString(),
                    zbpbs4 = dr["zbpbs4"].ToString(),
                    zbpyl2 = dr["zbpyl2"].ToString(),
                    zbpyl3 = dr["zbpyl3"].ToString(),
                    zbpyl4 = dr["zbpyl4"].ToString(),
                    zbpremark2 = dr["zbpremark2"].ToString(),
                    zbpremark3 = dr["zbpremark3"].ToString(),
                    zbpremark4 = dr["zbpremark4"].ToString(),

                    zbptype1 = dr["zbptype1"].ToString(),
                    zbpname1 = dr["zbpname1"].ToString(),
                    zbpbs1 = dr["zbpbs1"].ToString(),
                    zbpremark1 = dr["zbpremark1"].ToString(),
                    zbpyl1 = dr["zbpyl1"].ToString(),
                    infofv3 = dr["infofv3"].ToString(),
                    infofv6 = dr["infofv6"].ToString(),

                    zbpunit1 = dr["zbpunit1"].ToString(),
                    zbpunit2 = dr["zbpunit2"].ToString(),
                    zbpunit3 = dr["zbpunit3"].ToString(),
                    zbpunit4 = dr["zbpunit4"].ToString(),
                });
            }

            foreach (DataRow dr in dt_taskGet.Rows)//采收
            {
                alls.Add(new showinfoall
                {
                    worktfl = "taskGet",
                    worktime2 = DateTime.Parse(dr["infodt1"].ToString()),
                    dayTctype = dr["infofv4"].ToString(),
                    worktype = "采收",
                    worktoolname = "",
                    workfjobj = "",
                    infonv3 = dr["infonv3"].ToString(),
                    infonv6 = dr["infonv6"].ToString(),
                    infofv3 = dr["infofv3"].ToString(),
                    infofv12 = dr["infofv12"].ToString(),
                });
            }

            foreach (DataRow dr in dt_自加工出库.Rows)//自加工
            {
                alls.Add(new showinfoall
                {
                    worktfl = "seftjgout",
                    worktime2 = DateTime.Parse(dr["dataaddtime"].ToString()),
                    dayTctype = "",
                    worktype = "农场加工",
                    worktoolname = "",
                    workfjobj = "",

                    productstate = dr["productstate"].ToString(),
                    productname = dr["productname"].ToString(),
                    inouttype = dr["inouttype"].ToString(),
                    storeall = dr["storeall"].ToString(),
                    storefortype1 = dr["storefortype1"].ToString(),
                    storefortype2 = dr["storefortype2"].ToString(),
                    storefortype3 = dr["storefortype3"].ToString(),
                    dataaddusername = dr["dataaddusername"].ToString(),
                    outdesc = dr["outdesc"].ToString(),
                });
            }


            foreach (DataRow dr in dt_自加工入库.Rows)//自加工完成
            {
                alls.Add(new showinfoall
                {
                    worktfl = "seftjgend",
                    worktime2 = DateTime.Parse(dr["dataaddtime"].ToString()),
                    dayTctype = "",
                    worktype = "自加工完成",
                    worktoolname = "",
                    workfjobj = "",

                    productstate = dr["productstate"].ToString(),
                    productname = dr["productname"].ToString(),
                    inouttype = dr["inouttype"].ToString(),
                    storealluseall = dr["storealluseall"].ToString(),
                    storeall = dr["storeall"].ToString(),
                    storefortype1 = dr["storefortype1"].ToString(),
                    storefortype2 = dr["storefortype2"].ToString(),
                    storefortype3 = dr["storefortype3"].ToString(),
                    dataaddusername = dr["dataaddusername"].ToString(),
                    // outdesc = dr["outdesc"].ToString(),
                    remarks = dr["remarks"].ToString(),
                });
            } var 运输日志ID = "";
            using (dbsimple db = new dbsimple())
            {
                foreach (DataRow dr in dt_基地库出库运输.Rows)//基地库出库运输
                {
                    var 运输日志 = "";
                    var dtlog = db.Query(string.Format("SELECT * from yw_sp_log   where mid='{0}' and type=20171007 ", dr["outgid"].ToString()));
                    foreach (DataRow drlog in dtlog.Rows)
                    {
                        if (运输日志ID.IndexOf(drlog["id"].ToString()) >= 0) continue;
                        运输日志ID += drlog["id"].ToString();
                        运输日志 += string.Format(" 天气：{0} 温度：{1} 说明：{2}", drlog["fv2"].ToString(), drlog["fv1"].ToString(), drlog["fv5"].ToString());
                    }

                    alls.Add(new showinfoall
                    {
                        worktfl = "sefttocenter",
                        worktime2 = DateTime.Parse(dr["dataaddtime"].ToString()),
                        dayTctype = "",
                        worktype = "基地出库",
                        worktoolname = "",
                        workfjobj = "",

                        productstate = dr["productstate"].ToString(),
                        productname = dr["productname"].ToString(),
                        inouttype = dr["inouttype"].ToString(),
                        storealluseall = dr["storealluseall"].ToString(),
                        storeall = dr["storeall"].ToString(),
                        carinfo = "" + dr["carinfo"].ToString() + " 状态：" + dr["outstate"].ToString() + (string.IsNullOrEmpty(dr["endtime"].ToString()) ? "" : " 运输完成时间：" + DateTime.Parse(dr["endtime"].ToString()).ToString("yyyy-MM-dd")) + "",
                        storefortype1 = dr["storefortype1"].ToString(),
                        storefortype2 = dr["storefortype2"].ToString(),
                        storefortype3 = dr["storefortype3"].ToString(),
                        dataaddusername = dr["dataaddusername"].ToString(),
                        outdesc = dr["outdesc"].ToString(),
                        logforys1 = 运输日志

                        // remarks = dr["remarks"].ToString(),
                    });
                }
            }
            foreach (DataRow dr in dt_中心库运输入库.Rows)//批次中心库运输入库
            {
                alls.Add(new showinfoall
                {
                    worktfl = "pccenterin",
                    worktime2 = DateTime.Parse(dr["dataaddtime"].ToString()),
                    dayTctype = "",
                    worktype = "中心接收",
                    worktoolname = "",
                    workfjobj = "",

                    productstate = dr["productstate"].ToString(),
                    productname = dr["productname"].ToString(),
                    inouttype = dr["inouttype"].ToString(),
                    storealluseall = dr["storealluseall"].ToString(),
                    storeall = dr["storeall"].ToString(),
                    //carinfo = dr["carinfo"].ToString(),
                    storefortype1 = dr["storefortype1"].ToString(),
                    storefortype2 = dr["storefortype2"].ToString(),
                    storefortype3 = dr["storefortype3"].ToString(),
                    dataaddusername = dr["dataaddusername"].ToString(),
                    inoutstorestate = dr["inoutstorestate"].ToString(),
                    outdesc = dr["outdesc"].ToString(),
                    //remarks = dr["remarks"].ToString(),
                    outstate = dr["outstate"].ToString(),
                });
            }

            foreach (DataRow dr in dt_取原料.Rows)//批次中心库取料加工
            {
                alls.Add(new showinfoall
                {
                    worktfl = "pccenterjgout",
                    worktime2 = DateTime.Parse(dr["dataaddtime"].ToString()),
                    dayTctype = "",
                    worktype = "中心加工",
                    worktoolname = "",
                    workfjobj = "",

                    productstate = dr["productstate"].ToString(),
                    productname = dr["productname"].ToString(),
                    inouttype = dr["inouttype"].ToString(),
                    storealluseall = dr["storealluseall"].ToString(),
                    storeall = dr["storeall"].ToString(),
                    // carinfo = dr["carinfo"].ToString(),
                    storefortype1 = dr["storefortype1"].ToString(),
                    storefortype2 = dr["storefortype2"].ToString(),
                    storefortype3 = dr["storefortype3"].ToString(),
                    dataaddusername = dr["dataaddusername"].ToString(),
                    inoutstorestate = dr["inoutstorestate"].ToString(),
                    outdesc = dr["outdesc"].ToString(),
                    // remarks = dr["remarks"].ToString(),
                    outstate = dr["outstate"].ToString(),
                });
            }

            foreach (DataRow dr in 中心加工完成入库.Rows)//批次中心库取料加工完成及半成品进入待发库
            {
                alls.Add(new showinfoall
                {
                    worktfl = "pccenterjgend",
                    worktime2 = DateTime.Parse(dr["dataaddtime"].ToString()),
                    dayTctype = "",
                    worktype = "中心加工完成",
                    worktoolname = "",
                    workfjobj = "",

                    productstate = dr["productstate"].ToString(),
                    productname = dr["productname"].ToString(),
                    inouttype = dr["inouttype"].ToString(),
                    storealluseall = dr["storealluseall"].ToString(),
                    storeall = dr["storeall"].ToString(),
                    //carinfo = dr["carinfo"].ToString(),
                    storefortype1 = dr["storefortype1"].ToString(),
                    storefortype2 = dr["storefortype2"].ToString(),
                    storefortype3 = dr["storefortype3"].ToString(),
                    dataaddusername = dr["dataaddusername"].ToString(),
                    inoutstorestate = dr["inoutstorestate"].ToString(),
                    outdesc = dr["outdesc"].ToString(),
                    // remarks = dr["remarks"].ToString(),
                    outstate = dr["outstate"].ToString(),
                });
            }


            foreach (DataRow dr in dt_贴码记录信息.Rows)//中心库贴码信息
            {
                alls.Add(new showinfoall
                {
                    worktfl = "taskcodeinfo",
                    worktime2 = DateTime.Parse(dr["dataaddtime"].ToString()),
                    dayTctype = "",
                    worktype = dr["inouttype"].ToString() == "预分配" ? "贴码明细(预)" : "贴码明细(补)",
                    worktoolname = "",
                    workfjobj = "",
                    storeall = dr["codecount"].ToString(),
                    productstate = dr["productstate"].ToString(),
                    productname = dr["productname"].ToString(),
                    dataaddusername = dr["dataaddusername"].ToString(),
                    startcode = dr["startcode"].ToString(),
                    endcode = dr["endcode"].ToString(),
                    outdesc = dr["outdesc"].ToString(),
                    remarks = dr["remarks"].ToString(),
                });
            }


            using (dbsimple db = new dbsimple())
            {
                var 运输日志ID2 = "";
                foreach (DataRow dr in dt_发到商超.Rows)//批次发贷信息
                {
                    var 运输日志 = "";
                    var dtlog = db.Query(string.Format("SELECT * from yw_sp_log   where mid='{0}' and type=20171007 ", dr["outgid"].ToString()));
                    foreach (DataRow drlog in dtlog.Rows)
                    {
                        if (运输日志ID2.IndexOf(drlog["id"].ToString()) >= 0) continue;
                        运输日志ID2 += drlog["id"].ToString();
                        运输日志 += string.Format(" 天气：{0} 温度：{1} 说明：{2}", drlog["fv2"].ToString(), drlog["fv1"].ToString(), drlog["fv5"].ToString());
                    }
                    alls.Add(new showinfoall
                    {
                        worktfl = "pccenterouttoend",
                        worktime2 = DateTime.Parse(dr["dataaddtime"].ToString()),
                        dayTctype = "",
                        worktype = "发货",
                        worktoolname = "",
                        workfjobj = "",

                        productstate = dr["productstate"].ToString(),
                        productname = dr["productname"].ToString(),
                        inouttype = dr["inouttype"].ToString(),
                        // carinfo = dr["carinfo"].ToString(),
                        scname = dr["scname"].ToString(),
                        inoutstorestate = dr["inoutstorestate"].ToString(),
                        storealluseall = dr["storealluseall"].ToString(),
                        storeall = dr["storeall"].ToString(),
                        storefortype1 = dr["storefortype1"].ToString(),
                        storefortype2 = dr["storefortype2"].ToString(),
                        storefortype3 = dr["storefortype3"].ToString(),
                        dataaddusername = dr["dataaddusername"].ToString(),
                        remarks = dr["remarks"].ToString(),
                        outdesc = dr["outdesc"].ToString(),
                        logforys1 = 运输日志
                    });
                }
            }
            alls = alls.OrderBy(m => m.worktime2).ToList();
            foreach (var list in alls)
            {
                list.outdesc = list.outdesc==null?"":(list.outdesc.Replace("处理中", "").Replace("出库中", "").Replace("待出库处理", ""));
                list.remarks = list.remarks == null ? "" : (list.remarks.Replace("处理中", "").Replace("出库中", "").Replace("待出库处理", ""));
                list.worktime = list.worktime2.ToString("yyyy-MM-dd");
            }
            string allworks = JsonConvert.SerializeObject(alls);


            //foreach (DataRow dr in dt_发到商超.Rows)//批次发贷信息
            //{
            //    alls.Add(new showinfoall
            //    {
            //        worktfl = "taskworkbj",
            //        worktime = (DateTime)dr["infodt1"],
            //        dayTctype = "",
            //        worktype = "备注",
            //        worktoolname = "",
            //        workfjobj = "",

            //        infofv6 = dr["infofv6"].ToString(),

            //    });
            //}

            var reinfo = "{\"task\":" + task + ",\"allworks\":" + allworks
                + "}";

            return reinfo;

        }


        /// <summary>
        /// 根据 日期 找所有采收发货信息
        /// </summary>
        /// <param name="time">2018 2018-04 2018-04-01</param>
        /// <param name="type">y m d 年月日</param>
        /// <param name="branchid">机构ID</param>
        /// <returns></returns>
        [ActionName("GetWorkAllInfoByTaskId")]
        [HttpGet]
        public string GetWorkAllInfoByTaskId(string time, string type, string branchid)
        {
            DataTable 所有包装规格 = null;
            DataTable 所有包装规格明细 = null;
            string 本次查询的规格 = "";
            using (dbsimple db = new dbsimple())
            {
                所有包装规格 = db.Query("select DISTINCT fv3,0 as hcggindex from yw_baseinfo where type=7  ORDER BY nv1 ");
                所有包装规格明细 = db.Query(" select id,fv1 as spid,fv3,nv1,nv2 from yw_baseinfo where type=7  ORDER BY fv1,nv2  ");
            }



            DataTable dt = new DataTable("Product");
            //DataColumn dc = null;
            //添加列，赋值
            dt.Columns.Add("spid");
            dt.Columns.Add("spfl");
            dt.Columns.Add("spname");
            dt.Columns.Add("inallcount");
            dt.Columns.Add("outbjallcount");
            dt.Columns.Add("outbjallcount_sl");
            //dt.Columns.Add("outbjallcount");
            dt.Columns.Add("ccl");
            dt.Columns.Add("ylcount");
            dt.Columns.Add("allcount");
            int 规格index = 9;
            int 总规格数 = 所有包装规格.Rows.Count;
            //foreach (DataRow dr in 所有包装规格.Rows)//10
            //{
            dt.Columns.Add("gg1"); dt.Columns.Add("gg2"); dt.Columns.Add("gg3"); dt.Columns.Add("gg4"); dt.Columns.Add("gg5");
            dt.Columns.Add("gg6");
            dt.Columns.Add("gg7");
            dt.Columns.Add("gg8");
            dt.Columns.Add("gg9");
            //}
            string sqltimeformat = "%Y-%m-%d";
            if (type == "y") sqltimeformat = "%Y";
            else if (type == "m") sqltimeformat = "%Y-%m";
            string sql = @"select *,包装得出重量+原料发货量 总量 FROM
(
select t1.id 品ID,t1.fv5 分类,t1.fv1 品名,tget.inallcount 采收,tsetbj.outbjallcount 包装品发货总量,tsetbj.outtype1bjallcount 
,tsetbj.outtype2bjallcount 
,tsetbj.outtype3bjallcount 
,tsetbj.outtype4bjallcount 
,(tsetbj.outtype1bjallcount+tsetbj.outtype2bjallcount +tsetbj.outtype3bjallcount +tsetbj.outtype4bjallcount  ) as  包装品发货总数
,tsetbj.outbjallcount as 包装得出重量
,FORMAT(tsetbj.outbjallcount*100/tget.inallcount,2) as 出成率
,(CASE WHEN  tsetyl.outylallcount is null THEN 0  ELSE  tsetyl.outylallcount END )  原料发货量
 from yw_baseinfo as t1  
left join 

(SELECT   productid,productname,sum(storeall)as inallcount from hsc_task_store 
where date_format(dataaddtime,'{0}') ='{1}'  and databranchid={2} and  inouttype='采摘入库' and productstate='原料' 
 GROUP BY productid ) as tget on t1.id=tget.productid

left join 
(SELECT  productid,productname ,sum(storeall)as outbjallcount,SUM(storefortype1) outtype1bjallcount
,SUM(storefortype2) outtype2bjallcount
,SUM(storefortype3) outtype3bjallcount
,SUM(storefortype4) outtype4bjallcount
 from hsc_task_store_out 
where 
date_format(dataaddtime,'{0}') ='{1}'  and databranchid={2} and 
inouttype='发往加工中心' and productstate='包装品'
 GROUP BY productid  ) as tsetbj on t1.id=tsetbj.productid


left join 
(SELECT   productid,productname ,sum(storeall)as outylallcount  from hsc_task_store_out 
where date_format(dataaddtime,'{0}') ='{1}'  and databranchid={2}  and 
inouttype='发往加工中心' and productstate='原料'
 GROUP BY productid   ) as tsetyl on t1.id=tsetyl.productid


where t1.type=1
) as allinfo
where (allinfo.`采收` is not null )or (allinfo.`包装品发货总量` is not null)";　//or 条件重要
            sql = string.Format(sql, sqltimeformat, time, branchid);
            DataTable dt_采收发货信息 = null;
            using (dbsimple db = new dbsimple())
            {
                dt_采收发货信息 = db.Query(sql);
            }
            //本次查询用上的规格
            DataTable 所有包装规格re = 所有包装规格.Clone();
            foreach (DataRow dr in dt_采收发货信息.Rows)
            {

                var newdtdr = dt.NewRow();
                newdtdr["spid"] = dr["品ID"].ToString();
                newdtdr["spfl"] = dr["分类"].ToString();
                newdtdr["spname"] = dr["品名"].ToString();
                newdtdr["inallcount"] = dr["采收"].ToString();
                newdtdr["outbjallcount"] = dr["包装品发货总量"].ToString();
                newdtdr["outbjallcount_sl"] = dr["包装品发货总数"].ToString();
                newdtdr["ccl"] = dr["出成率"].ToString();
                newdtdr["ylcount"] = dr["原料发货量"].ToString();
                newdtdr["allcount"] = dr["总量"].ToString();
                //当前品种的规格
                DataRow[] drs2 = 所有包装规格明细.Select("spid = '" + dr["品ID"].ToString() + "' ");

                for (int ggindex = 0; ggindex < drs2.Length; ggindex++)
                {
                    string 当前的位置 = "0";
                    本次查询的规格 += "," + drs2[ggindex]["fv3"].ToString() + ",";

                    foreach (DataRow drggre in 所有包装规格re.Rows)
                    {
                        if (drggre[0].ToString() == drs2[ggindex]["fv3"].ToString())
                        {
                            当前的位置 = drggre[1].ToString();
                            break;
                        }
                    }
                    if (当前的位置 == "0")//没有找到
                    {
                        var newdtggdr = 所有包装规格re.NewRow();//hcggindex
                        newdtggdr[0] = drs2[ggindex]["fv3"].ToString();
                        newdtggdr[1] = 所有包装规格re.Rows.Count + 1;
                        所有包装规格re.Rows.Add(newdtggdr);
                        当前的位置 = newdtggdr[1].ToString();
                    }



                    if (drs2[ggindex]["nv2"].ToString() == "1")
                    {
                        newdtdr["gg" + 当前的位置] = dr["outtype1bjallcount"].ToString();
                    }
                    else if (drs2[ggindex]["nv2"].ToString() == "2")
                    {
                        newdtdr["gg" + 当前的位置] = dr["outtype2bjallcount"].ToString();
                    }
                    else if (drs2[ggindex]["nv2"].ToString() == "3")
                    {
                        newdtdr["gg" + 当前的位置] = dr["outtype3bjallcount"].ToString();
                    }
                    else if (drs2[ggindex]["nv2"].ToString() == "4")
                    {
                        newdtdr["gg" + 当前的位置] = dr["outtype4bjallcount"].ToString();
                    }
                    else if (drs2[ggindex]["nv2"].ToString() == "5")
                    {
                        newdtdr["gg" + 当前的位置] = dr["outtype5bjallcount"].ToString();
                    }
                }
                dt.Rows.Add(newdtdr);
            }
            var task = JsonControl.GetJsonStr(dt);
            DataTable dtsum = dt.Clone();
            var drsum = dtsum.NewRow();//hcggindex
            drsum["inallcount"] = ColumnSum(dt, "inallcount");
            drsum["outbjallcount_sl"] = ColumnSum(dt, "outbjallcount_sl");
            drsum["outbjallcount"] = ColumnSum(dt, "outbjallcount");
            drsum["ccl"] = (ColumnSum(dt, "ccl") / dt.Rows.Count).ToString("F2");
            drsum["gg1"] = ColumnSum(dt, "gg1");
            drsum["gg1"] = ColumnSum(dt, "gg1");
            drsum["gg2"] = ColumnSum(dt, "gg2");
            drsum["gg3"] = ColumnSum(dt, "gg3");
            drsum["gg4"] = ColumnSum(dt, "gg4");
            drsum["gg5"] = ColumnSum(dt, "gg5");
            drsum["gg6"] = ColumnSum(dt, "gg6");
            drsum["gg7"] = ColumnSum(dt, "gg7");
            drsum["gg8"] = ColumnSum(dt, "gg8");
            drsum["ylcount"] = ColumnSum(dt, "ylcount");
            drsum["allcount"] = ColumnSum(dt, "allcount");


            dtsum.Rows.Add(drsum);


            var sumdt = JsonControl.GetJsonStr(dtsum);
            var allgginfo = JsonControl.GetJsonStr(所有包装规格re);
            var reinfo = "{\"dtgetset\":" + task + ",\"allgginfo\":" + allgginfo + ",\"sumdt\":" + sumdt + "}";

            return reinfo;


        }

        /// <summary>
        /// 任务-更新中心的入库时间到基地的发货记录表中
        /// </summary>
        /// <returns></returns>
        [ActionName("GetUpdateCenterInTimeToBaseOut")]
        [HttpGet]
        public string GetUpdateCenterInTimeToBaseOut(string id, string inguid = "", string intime = "")
        {

            try
            {
                if (string.IsNullOrEmpty(intime)) intime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
                using (dbsimple db = new dbsimple())
                {
                    //取出本次的处理信息的关键信息
                    var doinfo = db.Query("select taskid,taskfromorgid,productid,dataaddtime,productstate  from hsc_task_store_out_group where id= " + id);
                    //根据关键信息取出对应的基地发货记录,更新时间
                    db.SpExe(string.Format(@"update hsc_task_store_out set centerintime='{4}',
centeringuid='{0}',inoutstorestate='已入库'
where dataaddtime='{1}' 
and inoutstorestate in('待入库','入库中') 
and taskfromorgid={2}
and taskid={3} ",
                        inguid,
                        doinfo.Rows[0]["dataaddtime"].ToString(),
                        doinfo.Rows[0]["taskfromorgid"].ToString(),
                         doinfo.Rows[0]["taskid"].ToString(), intime
                        ));

                }
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
            return "处理成功";

        }


        //private double ColumnSum(DataTable dt, string ColumnName)
        //{
        //    double d = 0;
        //    foreach (DataRow row in dt.Rows)
        //    {
        //        d += double.Parse(row[ColumnName].ToString());
        //    }
        //    return d;
        //}  

        public string workfjobj { get; set; }
    }
    public class showinfoall
    {
        public string worktype { get; set; }public string worktime { get; set; }

        public DateTime worktime2 { get; set; }

        public string dayTctype { get; set; }

        public string worktfl { get; set; }

        public string worktoolname { get; set; }

        public string workfjobj { get; set; }

        public string zbptype1 { get; set; }

        public string zbpname1 { get; set; }

        public string zbpbs1 { get; set; }

        public string zbpremark1 { get; set; }

        public string zbpyl1 { get; set; }

        public string infofv3 { get; set; }

        public string infofv6 { get; set; }

        public string zbpremark2 { get; set; }

        public string zbpremark3 { get; set; }

        public string zbpremark4 { get; set; }

        public string zbpyl2 { get; set; }

        public string zbpyl3 { get; set; }

        public string zbpyl4 { get; set; }

        public string zbpbs2 { get; set; }

        public string zbpbs3 { get; set; }

        public string zbpbs4 { get; set; }

        public string zbptype2 { get; set; }

        public string zbptype3 { get; set; }

        public string zbptype4 { get; set; }

        public string infonv3 { get; set; }

        public string infonv6 { get; set; }

        public string infofv12 { get; set; }

        public string productstate { get; set; }

        public string productname { get; set; }

        public string inouttype { get; set; }

        public string storeall { get; set; }

        public string storefortype1 { get; set; }

        public string storefortype2 { get; set; }

        public string storefortype3 { get; set; }

        public string dataaddusername { get; set; }

        public string outdesc { get; set; }

        public string storealluseall { get; set; }

        public string remarks { get; set; }

        public string carinfo { get; set; }

        public string inoutstorestate { get; set; }

        public string outstate { get; set; }

        public string startcode { get; set; }

        public string endcode { get; set; }

        public string scname { get; set; }

        public string logforys1 { get; set; }

        public string zbpunit1 { get; set; }

        public string zbpunit2 { get; set; }

        public string zbpunit3 { get; set; }

        public string zbpunit4 { get; set; }
    }
    #region 参数对象
    public class codeinfo
    {
        public string startCode { get; set; }
        public string endCode { get; set; }
        /// <summary>
        /// 字符部分
        /// </summary>
        public string codeString { get; set; }
        /// <summary>
        /// endCode字符部分
        /// </summary>
        public string endcodeString { get; set; }
        public double startNum { get; set; }
        /// <summary>
        /// 数字长度
        /// </summary>
        public double NumLenth { get; set; }
        public double endNum { get; set; }
        public double codeCount { get; set; }
    }
    /// <summary>
    /// 加工数据流转
    /// </summary>
    public class workstoreoutinfo
    {
        public string id { get; set; }
        public double number { get; set; }
        public double numberb1 { get; set; }
        public double numberb2 { get; set; }
        public double numberb3 { get; set; }
        public string info { get; set; }

    }
    /// <summary>
    /// simpledata
    /// </summary>
    public class simpledata
    {

        public string id { get; set; }
    }

    public class OutListOutUpdate
    {

        #region 更新出库记录时
        public double listoutid { get; set; }
        public double oldcount { get; set; }
        public double newcount { get; set; }
        #endregion

    }
    #endregion
}
